home *** CD-ROM | disk | FTP | other *** search
- /*
- * File: YourTool.c
- *
- * Note: We designed this template to work with V.U. 2.0dx. If you have a more
- * recent version of V.U., please look for the current version of this file.
- *
- * To add functionality to this tool, replace all occurrences of 'YourTool'
- * and 'YourService' with your own names and supply the corresponding code.
- *
- * Contains: V.U. 2.0 External Tool C Template.
- *
- * This program receives and responds to Apple Events using the
- * V.U. 2.0 external tool Interface protocol.
- *
- * Written by: Automation Systems Team, Apple Computer, Inc.
- *
- */
-
- // Includes
- #include <Types.h>
- #include <Memory.h>
- #include <Packages.h>
- #include <Errors.h>
- #include <QuickDraw.h>
- #include <Fonts.h>
- #include <Dialogs.h>
- #include <Windows.h>
- #include <Menus.h>
- #include <Events.h>
- #include <OSEvents.h>
- #include <Desk.h>
- #include <DiskInit.h>
- #include <Resources.h>
- #include <ToolUtils.h>
- #include <AppleEvents.h>
- #include <EPPC.h>
- #include <GestaltEqu.h>
- #include <PPCToolbox.h>
- #include <Processes.h>
- #include <String.h>
- #include <VUAE.h>
-
- // Constants
- #define kMBarID 128
- #define kAppleMenu 128
- #define kFileMenu 129
- #define kEditMenu 130
- #define NIL 0L
- #define TRUE 1
- #define FALSE 0
- #define kSuspendResumeMessage 1
- #define kMouseMovedMessage 250
-
- // Your services
-
- OSErr YourService( AppleEvent msg, AppleEvent reply, long refCon );
-
- // VU required services
-
- pascal OSErr VUServiceHandler( AppleEvent msg, AppleEvent reply, long refCon );
-
- OSErr VUInitializeHandler( AppleEvent msg, AppleEvent reply, long refCon );
- OSErr VUCancelHandler( AppleEvent msg, AppleEvent reply, long refCon );
- OSErr VUSrvcListHandler( AppleEvent msg, AppleEvent reply, long refCon );
- OSErr VUVersionHandler( AppleEvent msg, AppleEvent reply, long refCon );
- OSErr VUHasSrvcHandler( AppleEvent msg, AppleEvent reply, long refCon );
- OSErr VUQuitHandler( AppleEvent msg, AppleEvent reply, long refCon );
-
- void AskForMoreTime( short requestedExtraTime, AppleEvent reply );
-
- // AppleEvent required services
-
- pascal OSErr AEOpenHandler( AppleEvent msg, AppleEvent reply, long refCon );
- pascal OSErr AEOpenDocHandler( AppleEvent msg, AppleEvent reply, long refCon );
- pascal OSErr AEQuitHandler( AppleEvent msg, AppleEvent reply, long refCon );
- pascal OSErr AEPrintHandler( AppleEvent msg, AppleEvent reply, long refCon );
-
- // Support
-
- void InitAEStuff(void);
- void InitProgram(void);
- void Idling(void);
- void InvokeDA (MenuHandle theMenu, long theItem);
- void BuildMenuBar(void);
- void MenuCommand (long theCmd);
- void DispatchMouseDown (EventRecord theEvent);
- void DispatchKeyDown (EventRecord theEvent);
- void ActivateWindow (WindowPtr theWindow, Boolean activating);
- void UpdateWindow (WindowPtr theWindow);
- void DiskInserted (long diskInfo);
- void DispatchOSEvent (EventRecord theEvent);
- void DispatchHighEvent (EventRecord theEvent);
- pascal OSErr VUErrorReply (AppleEvent *reply, Str255 errorText, OSErr errorNo);
- void ReportError (OSErr err, long where);
- void SrvcError (Str255 msg);
-
- // Globals
-
- Boolean hasAE, quitting, background;
- Handle theMenuBar;
- MenuHandle appleMenu, fileMenu, editMenu;
- EventRecord theEvent;
- OSErr aeError;
- Str255 strTemp1, strTemp2;
-
-
- // Service Table definition
- typedef struct {
- char* serviceName;
- OSErr (*serviceFunction)( AppleEvent, AppleEvent, long );
- } ServiceInfo;
-
- ServiceInfo VU_Tool_Services[] = {
- { "Initialize", VUInitializeHandler },
- { "Cancel", VUCancelHandler },
- { "GetToolServices", VUSrvcListHandler },
- { "GetToolVersion", VUVersionHandler },
- { "ServiceSupported", VUHasSrvcHandler },
- { "Quit", VUQuitHandler },
- //
- { "YourService", YourService },
- };
-
- const long NumberOfServices = (sizeof( VU_Tool_Services ) / sizeof( ServiceInfo ));
-
-
- // ** Functions **
- main()
- {
- // Main event loop. Just get events, and dispatch them to an
- // appropriate handler until we get the 'quit' command.
-
- InitProgram();
-
- while (!quitting) {
- WaitNextEvent (everyEvent, &theEvent, 30, NIL);
- switch (theEvent.what) {
- case nullEvent:
- Idling();
- break;
- case mouseDown:
- DispatchMouseDown(theEvent);
- break;
- case keyDown:
- case autoKey:
- DispatchKeyDown(theEvent);
- break;
- case activateEvt:
- ActivateWindow((WindowPtr)theEvent.message,
- (theEvent.modifiers & activeFlag) != 0);
- break;
- case updateEvt:
- UpdateWindow((WindowPtr)theEvent.message);
- break;
- case diskEvt:
- DiskInserted(theEvent.message);
- break;
- case osEvt:
- DispatchOSEvent(theEvent);
- break;
- case kHighLevelEvent:
- DispatchHighEvent(theEvent);
- break;
- }
- }
- }
-
-
- OSErr ExtractShortFromAEList( AEDescList paramList, long index, short* result )
- {
- OSErr aeErr;
- AEKeyword paramKeyword;
- DescType actualType;
- Size actualSize;
-
- aeErr = AEGetNthPtr( ¶mList,
- index,
- typeShortInteger,
- ¶mKeyword,
- &actualType,
- (Ptr) result,
- sizeof( *result ),
- &actualSize );
- if( aeErr )
- {
- ReportError( aeErr, 13 );
- }
-
- return( aeErr );
- }
-
- OSErr ExtractStringFromAEList( AEDescList paramList, long index, char* string)
- {
- OSErr aeErr;
- AEKeyword paramKeyword;
- DescType actualType;
- Size actualSize;
-
- aeErr = AEGetNthPtr( ¶mList,
- index,
- typeChar,
- ¶mKeyword,
- &actualType,
- (Ptr) string,
- 255,
- &actualSize );
- if( aeErr )
- {
- ReportError( aeErr, 13 );
- }
- else
- {
- string[actualSize] = '\0';
- }
-
- return( aeErr );
- }
-
-
- pascal OSErr VUServiceHandler(AppleEvent msg, AppleEvent reply, long refcon)
- {
- OSType vuEventClass;
- OSErr aeErr;
- Str255 serviceName = "";
- DescType actualType;
- Size actualSize;
- long i;
-
- // Get the AE Service Name
- aeErr = AEGetParamPtr(&msg,
- kVUAESrvcName,
- typeChar,
- &actualType,
- serviceName,
- 255,
- &actualSize);
- ReportError(aeErr, 1);
- if( aeErr == noErr )
- {
- serviceName[ actualSize ] = '\0';
- }
-
- vuEventClass = kVUAETool;
- aeErr = AEPutAttributePtr( &reply,
- keyEventClassAttr,
- typeType,
- (Ptr) &vuEventClass,
- sizeof(OSType));
- if( aeErr )
- {
- ReportError(aeErr, 2);
- }
-
- for( i = 0; i < NumberOfServices; i++ )
- {
- if( !relstring( serviceName, VU_Tool_Services[ i ].serviceName, false, true ) )
- {
- aeErr = (*(VU_Tool_Services[ i ].serviceFunction))( msg, reply, refcon );
- return( aeErr );
- }
- }
-
- // SrvcError( (Str255)serviceName );
- return( errAEUnknownService);
- }
-
- OSErr VUInitializeHandler( AppleEvent /* msg */, AppleEvent reply, long /* refCon */ )
- {
- OSErr aeErr;
-
- aeErr = AEPutParamPtr( &reply,
- kVUAESrvcResults,
- typeTrue,
- NIL,
- 0);
- return( aeErr );
- }
-
- OSErr VUCancelHandler( AppleEvent /* msg */, AppleEvent /* reply */, long /* refCon */ )
- {
- return noErr;
- }
-
- OSErr VUQuitHandler( AppleEvent /* msg */, AppleEvent /* reply */, long /* refCon */ )
- {
- quitting = TRUE;
- return noErr;
- }
-
- OSErr VUVersionHandler( AppleEvent, AppleEvent reply, long )
- {
- // This Service asks an external tool to respond
- // with version information about itself.
-
- // The tool name is used by V.U. 2.0 as the name of a tool as shown to a user.
- // Thus, this should be something descriptive; e.g., 'Screen Capture Tool'.
-
- // The version number is simply a number returned to the caller indicating
- // the version of the tool. A V.U. 2.0 script writer could perhaps use this
- // information in verifying that the current release of an external tool was
- // present.
-
- // The version string simply allows more information to be sent by the external
- // tool. V.U. 2.0 does not use the version string.
-
- // This routine simply stuffs values into
- // the Apple Event reply using Apple Event Manager routines.
-
- OSErr aeErr;
- AEDescList srvcList;
- char* strPtr;
-
- aeErr = AECreateList( NIL, 0, FALSE, &srvcList );
- if( aeErr )
- {
- ReportError( aeErr, 3 );
- return( aeErr );
- }
-
-
- strPtr = "YourTool";
- aeErr = AEPutPtr( &srvcList,
- 1,
- typeChar,
- strPtr,
- strlen( strPtr ) );
- if( aeErr )
- {
- ReportError( aeErr, 4 );
- }
- else
- {
- strPtr = "2.0";
- aeErr = AEPutPtr( &srvcList,
- 2,
- typeChar,
- strPtr,
- strlen( strPtr ) );
- if( aeErr )
- {
- ReportError( aeErr, 5 );
- }
- else
- {
- strPtr = "2.0 by the Automation Systems Team, Apple Computer, Inc.";
- aeErr = AEPutPtr( &srvcList,
- 3,
- typeChar,
- strPtr,
- strlen( strPtr ) );
- if( aeErr )
- {
- ReportError( aeErr, 6 );
- }
- else
- {
- aeErr = AEPutKeyDesc( &reply,
- kVUAESrvcResults,
- &srvcList );
- if( aeErr )
- {
- ReportError( aeErr, 7 );
- }
- }
- }
- }
-
- AEDisposeDesc( &srvcList );
- return( aeErr );
- }
-
-
- OSErr VUHasSrvcHandler( AppleEvent msg, AppleEvent reply, long )
- {
- // This Service asks an external tool whether a
- // service with a specific name is supported by the tool.
-
- // The routine first extracts the service name from the Apple Event. If the
- // service name cannot be extracted for some reason from the Apple Event,
- // a standard error reply message is sent back to V.U. 2.0.
-
- // The routine simply returns the AppleEvent standard types 'typeTrue' or
- // 'typeFalse' depending on whether the service name is supported by the
- // tool or not. The Apple Event Manager will coerce these standard types
- // into an Apple Event Boolean value if necessary (and requested by V.U. 2.0).
-
- OSErr aeErr;
- Str255 serviceName;
- long i;
-
- AEDescList paramList;
- long numParams;
-
-
- aeErr = AEGetParamDesc( &msg,
- kVUAESrvcParameters,
- typeAEList,
- ¶mList );
- if( aeErr )
- {
- ReportError( aeErr, 14 );
- return( aeErr );
- }
-
- if( aeErr = AECountItems( ¶mList, &numParams ) )
- {
- ReportError( aeErr, 15 );
- }
- else if( numParams != 1 )
- {
- if( aeErr = VUErrorReply( &reply,
- "Incorrect number of parameters supplied!",
- errAEWrongParameters ) )
- {
- ReportError( aeErr, 16 );
- }
- aeErr = errAEWrongParameters;
- }
- else if( aeErr = ExtractStringFromAEList( paramList, 1, serviceName ) )
- {
- ReportError( aeErr, 17 );
- }
-
- AEDisposeDesc( ¶mList );
-
- if( aeErr )
- {
- return( aeErr );
- }
-
- for( i = 0; i < NumberOfServices; i++ )
- {
- if( !relstring( serviceName, VU_Tool_Services[ i ].serviceName, false, true ) )
- {
- aeErr = AEPutParamPtr( &reply,
- kVUAESrvcResults,
- typeTrue,
- NIL,
- 0);
- return( aeErr );
- }
- }
-
- aeErr = AEPutParamPtr( &reply,
- kVUAESrvcResults,
- typeFalse,
- NIL,
- 0);
- if( aeErr )
- {
- ReportError(aeErr, 9);
- return( aeErr );
- }
-
- return(aeErr);
- }
-
-
- OSErr VUSrvcListHandler( AppleEvent, AppleEvent reply, long )
- {
- // This Service asks an external tool for a list of
- // all service names supported by the tool.
-
- // Remember that Apple Event Lists are all one (1) based; i.e., indexes
- // start from one (not zero).
-
- // The first step creates an Apple Event List descriptor. This is followed by
- // stuffing each service name into the list, starting at index number one.
- // Once the list if filled with the service names, the list itself is inserted
- // into the Apple Event reply.
-
- OSErr aeErr;
- AEDescList srvcList;
- char* strPtr;
- long i;
-
- aeErr = AECreateList( NIL, 0, FALSE, &srvcList );
- if( aeErr )
- {
- ReportError( aeErr, 10 );
- return( aeErr );
- }
-
- for( i = 0; i < NumberOfServices; i++ )
- {
- strPtr = VU_Tool_Services[ i ].serviceName;
- aeErr = AEPutPtr( &srvcList,
- i + 1,
- typeChar,
- strPtr,
- strlen( strPtr ) );
- if( aeErr )
- {
- ReportError( aeErr, 11 );
- AEDisposeDesc( &srvcList );
- return( aeErr );
- }
- }
-
-
- aeErr = AEPutKeyDesc( &reply,
- kVUAESrvcResults,
- &srvcList );
- if( aeErr )
- {
- ReportError( aeErr, 12 );
- }
-
- AEDisposeDesc( &srvcList );
-
- return( aeErr );
- }
-
-
- OSErr YourService( AppleEvent msg, AppleEvent reply, long )
- {
- OSErr aeErr;
- AEDescList paramList;
- long numParams;
- short leftNumber, rightNumber, result;
-
-
- aeErr = AEGetParamDesc( &msg,
- kVUAESrvcParameters,
- typeAEList,
- ¶mList );
- if( aeErr )
- {
- ReportError( aeErr, 14 );
- return( aeErr );
- }
-
- if( aeErr = AECountItems( ¶mList, &numParams ) )
- {
- ReportError( aeErr, 15 );
- }
- else if( numParams != 2 )
- {
- if( aeErr = VUErrorReply( &reply,
- "You supplied the wrong number of parameters.",
- errAEWrongParameters ) )
- {
- ReportError( aeErr, 16 );
- }
- aeErr = errAEWrongParameters;
- }
- else if( aeErr = ExtractShortFromAEList( paramList, 1, &leftNumber ) )
- {
- ReportError( aeErr, 17 );
- }
- else if( aeErr = ExtractShortFromAEList( paramList, 2, &rightNumber ) )
- {
- ReportError( aeErr, 18 );
- }
-
- AEDisposeDesc( ¶mList );
-
- if( aeErr )
- {
- return( aeErr );
- }
-
- result = leftNumber + rightNumber;
-
- aeErr = AEPutParamPtr( &reply,
- kVUAESrvcResults,
- typeShortInteger,
- (Ptr) &result,
- sizeof( result ) );
- if( aeErr )
- {
- ReportError( aeErr, 19 );
- return( aeErr );
- }
-
- return( aeErr );
- }
-
- void AskForMoreTime( short requestedExtraTime, AppleEvent reply )
- {
- AppleEvent moreTimeRequestEvent;
- AppleEvent dummyReply;
- OSErr aeErr;
- OSType vuEventId;
- unsigned long extraTime;
-
- aeErr = AEDuplicateDesc( &reply, &moreTimeRequestEvent );
- if( aeErr )
- {
- ReportError( aeErr, 50 );
- }
- else
- {
- vuEventId = kVUAEWaitLonger;
- aeErr = AEPutAttributePtr( &moreTimeRequestEvent,
- keyEventIDAttr,
- typeType,
- (Ptr) &vuEventId,
- sizeof( OSType ) );
- if( aeErr )
- {
- ReportError( aeErr, 51 );
- }
-
- extraTime = requestedExtraTime;
- aeErr = AEPutParamPtr( &moreTimeRequestEvent, kVUAEWaitAmount, typeMagnitude,
- (Ptr)&extraTime, sizeof( extraTime ) );
- if( aeErr )
- {
- ReportError( aeErr, 52 );
- }
-
- aeErr = AESend( &moreTimeRequestEvent,
- &dummyReply,
- kAENoReply + kAENeverInteract,
- kAENormalPriority,
- kNoTimeOut,
- NULL,
- NULL );
- if( aeErr )
- {
- ReportError( aeErr, 53 );
- }
-
- aeErr = AEDisposeDesc( &moreTimeRequestEvent );
- if( aeErr )
- {
- ReportError( aeErr, 54 );
- }
- }
- }
-
- pascal OSErr AEOpenHandler(AppleEvent, AppleEvent, long)
- {
- // Standard (empty) handler for the 'oapp' Apple Event. Our program does
- // not need anything special here, so "noErr" can simply be returned.
-
- return(noErr);
- }
-
-
- pascal OSErr AEOpenDocHandler(AppleEvent, AppleEvent, long)
- {
- // Standard (empty) handler for the 'odoc' Apple Event. Our program does
- // not have documents, so we ignore this Apple Event.
-
- return(noErr);
- }
-
-
- pascal OSErr AEQuitHandler(AppleEvent, AppleEvent, long)
- {
- // Standard handler for the 'quit' Apple Event. You must never, ever call
- // ExitToShell from within an Apple Event handler. It is certain death
- // for your application. Thus, we just set a flag which is examined later
- // in the main event loop.
-
- quitting = TRUE;
- return(noErr);
- }
-
-
- pascal OSErr AEPrintHandler(AppleEvent, AppleEvent, long)
- {
- // Standard (empty) handler for the 'pdoc' Apple Event. Our program does
- // not have documents, so we ignore this Apple Event.
-
- return(noErr);
- }
-
-
- void ReportError(OSErr err, long where)
- {
- // Reports an error by way of an Alert dialog. "err" is the error
- // code. "where" is an arbitrary (but unique) number indicating
- // where in the program the error occurred. Of course, if there
- // is no error, this routine does nothing.
-
- int dontCare;
- Str255 errStr, whereStr;
-
- if (err != 0) {
- numtostring(err, errStr);
- numtostring(where, whereStr);
- paramtext(errStr, whereStr, '', '');
- dontCare = Alert(128, NIL);
- }
- }
-
-
- void SrvcError(Str255 msg)
- {
- // Displays an error dialog when the service name sent by V.U. 2.0
- // does not conform to a legal service understood by the external
- // tool. In reality, this program should check the Apple Event
- // user interaction level to determine how (and whether) to interact
- // with the user.
-
- int dontCare;
-
- paramtext(msg, '', '', '');
- dontCare = Alert(128, NIL);
- }
-
- pascal OSErr VUErrorReply(AppleEvent *reply, Str255 errorText, OSErr errorNo)
- {
- OSErr aeErr;
-
- aeErr = AEPutParamPtr(reply,
- keyErrorString,
- typeChar,
- errorText,
- strlen(errorText));
- if (aeErr == noErr) {
- aeErr = AEPutParamPtr(reply,
- keyErrorNumber,
- typeShortInteger,
- (Ptr)&errorNo,
- sizeof(errorNo));
- }
- return(aeErr);
- }
-
-
- void InitAEStuff(void)
- {
- // Initialization of the Apple Event Manager and dispatch table.
- // If we don't have Apple Events or installation of any of the
- // Apple Event handlers fails, the program is simply terminated.
- // The routine starts by installing standard handlers for the
- // core Apple Events. This is followed by installation of the
- // event handlers for the V.U. 2.0 external tool interface.
-
- long response;
- OSErr aeErr;
-
- hasAE = (Gestalt(gestaltAppleEventsAttr, &response) == noErr);
- if (hasAE) { // Has AE
- aeErr = AEInstallEventHandler(kVUAETool,
- kVUAESendService,
- (EventHandlerProcPtr) VUServiceHandler,
- 0, FALSE);
- if (aeErr != noErr) ExitToShell();
- aeErr = AEInstallEventHandler(kCoreEventClass,
- kAEOpenApplication,
- (EventHandlerProcPtr) AEOpenHandler,
- 0, FALSE);
- if (aeErr != noErr) ExitToShell();
- aeErr = AEInstallEventHandler(kCoreEventClass,
- kAEOpenDocuments,
- (EventHandlerProcPtr) AEOpenDocHandler,
- 0, FALSE);
- if (aeErr != noErr) ExitToShell();
- aeErr = AEInstallEventHandler(kCoreEventClass,
- kAEQuitApplication,
- (EventHandlerProcPtr) AEQuitHandler,
- 0, FALSE);
- if (aeErr != noErr) ExitToShell();
- aeErr = AEInstallEventHandler(kCoreEventClass,
- kAEPrintDocuments,
- (EventHandlerProcPtr) AEPrintHandler,
- 0, FALSE);
- if (aeErr != noErr) ExitToShell();
- aeErr = AESetInteractionAllowed(kAEInteractWithAll);
- if (aeErr != noErr) ExitToShell();
- }
- else
- ExitToShell();
- }
-
-
- void BuildMenuBar(void)
- {
- // Construct a menu bar for our application. (Yawn)
-
- theMenuBar = GetNewMBar(kMBarID);
- SetMenuBar(theMenuBar);
- appleMenu = GetMHandle(kAppleMenu);
- fileMenu = GetMHandle(kFileMenu);
- editMenu = GetMHandle(kEditMenu);
- AddResMenu(appleMenu, 'DRVR');
- DrawMenuBar();
- }
-
-
- void InitProgram(void)
- {
- // Initialize the Macintoshâ„¢ Toolbox and application
- // environment.
-
- quitting = FALSE;
- background = FALSE;
- MaxApplZone();
- InitGraf(&qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NIL);
- InitCursor();
-
- InitAEStuff();
- BuildMenuBar();
- }
-
-
- void Idling(void)
- {
- // We don't do anything while idling. Perhaps we should sing a song?
- }
-
-
- void InvokeDA(MenuHandle theMenu, long theItem)
- {
- // Bring up a desk accessory.
-
- OSErr err;
- Str255 da;
-
- GetItem(theMenu, theItem, da);
- err = OpenDeskAcc(da);
- }
-
-
- void MenuCommand(long theCmd)
- {
- // Activate the appropriate menu item.
-
- long menuID, menuItem;
- int dontCare;
-
- menuID = HiWord(theCmd);
- menuItem = LoWord(theCmd);
- switch (menuID ) {
- case kAppleMenu:
- if (menuItem != 1) InvokeDA(appleMenu, menuItem);
- else dontCare = Alert(666, NIL);
- break;
- case kFileMenu:
- quitting = TRUE;
- break;
- case kEditMenu: break;
- }
- HiliteMenu(0);
- }
-
-
- void DispatchMouseDown(EventRecord theEvent)
- {
- // Dispatch a mouse down event to the proper handler.
-
- WindowPtr theWindow;
-
- switch (FindWindow(theEvent.where, &theWindow)) {
- case inMenuBar:
- MenuCommand(MenuSelect(theEvent.where));
- break;
- case inSysWindow:
- SystemClick(&theEvent, theWindow);
- break;
- case inDrag:
- if (theWindow == FrontWindow())
- DragWindow(theWindow, theEvent.where, &qd.screenBits.bounds);
- break;
- case inContent: case inDesk: case inGrow: case inGoAway:
- break;
- }
- }
-
-
- void DispatchKeyDown(EventRecord theEvent)
- {
- // Dispatch a key down event to the proper handler. Since typing
- // isn't supported, the routine only checks for service key equivalents.
-
- char key;
-
- key = theEvent.message & charCodeMask;
- if ((theEvent.modifiers & cmdKey) && (theEvent.what == keyDown))
- MenuCommand(MenuKey(key));
- }
-
-
- void ActivateWindow(WindowPtr, Boolean)
- {
- // Gee, we don't have any windows worth activating.
- }
-
-
- void UpdateWindow(WindowPtr)
- {
- // Gee, we don't have any windows worth updating.
- }
-
- void DiskInserted(long diskInfo)
- {
- // Handle disk insert errors.
-
- Point where;
- OSErr dontCare;
-
- if (HiWord(diskInfo) != noErr) {
- SetPt(&where, 40, 40);
- dontCare = DIBadMount(where, diskInfo);
- }
- }
-
-
- void DispatchOSEvent(EventRecord theEvent)
- {
- // Dispatch OS events.
-
- switch ((theEvent.message >> 24) & 0x0FF) {
- case kMouseMovedMessage:
- Idling();
- break;
-
- case kSuspendResumeMessage:
- background = (theEvent.message & resumeFlag);
- ActivateWindow(FrontWindow(), !background);
- break;
- }
- }
-
-
- void DispatchHighEvent(EventRecord theEvent)
- {
- // Send off those Apple Events!
-
- aeError = AEProcessAppleEvent(&theEvent);
- }
-